import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  // 代理
  server: {
    proxy: {
      "/back": {
        target: "http://localhost:3000",
        changeOrigin: true,
      },
      "/front": {
        target: "http://localhost:3000",
        changeOrigin: true,
      },
      "/dev": {
        target: "http://localhost:3000",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev/, ""),
      },
    },
  },
  css: {
    modules: {
      localsConvention: "camelCase", // 将类名转换为 camelCase 格式
    },
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
});
